package com.ambow.user.test;

import java.util.List;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.ambow.user.dao.IUserDAO;
import com.ambow.user.dto.Article;
import com.ambow.user.dto.User;

public class SpringTestUser {

	private static ApplicationContext ctx;
	static {
		ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
	}

	@Test
	public void test() {
		IUserDAO dao = (IUserDAO) ctx.getBean("userDAO");
//		User user = dao.selectUserByID(1);
//		System.out.println(user.getUserAddress());
//
//		List<Article> articles = dao.getUserArticles(1);
//
//		for (Article article : articles) {
//			System.out.println(article.getContent() + "--" + article.getTitle());
//		}
		List<User> list=dao.selectUsers("%");
		for(User user:list){
			System.out.println("-----------------------------");
			System.out.println(user);
			for(Article article:user.getList()){
				System.out.println(article);
			}
		}
	}

}
